//
//  switchCellTableViewCell.m
//  FCTools
//
//  Created by WJC on 2018/10/25.
//  Copyright © 2018 wjc. All rights reserved.
//

#import "switchCellTableViewCell.h"
#import "WJCDefine.h"
#import "Masonry.h"
@implementation switchCellTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
       
        self.titleLabel=[[UILabel alloc]init];
        self.titleLabel.font=font15;
        self.titleLabel.text= @"" ;
        [self.contentView addSubview: self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(16);
            make.centerY.mas_equalTo(0);
        }];
        self.switchChoice=[[UISwitch alloc]initWithFrame:CGRectMake(WJCScreenW-66, (44-30)*0.5, 50, 30)];
        [self.contentView addSubview:_switchChoice];
        WJCSETLRViewBorderRadius(self.switchChoice, 15);
        [self.switchChoice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-16);
            make.centerY.mas_equalTo(0);
        }];
        [self.switchChoice addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
//        if (IphonePlus) {
//           self.titleLabel.font=font17;
//            self.switchChoice.y=10;
//            self.titleLabel.y=15;
//        }
    }
    return self;
}
-(void)switchChanged:(UISwitch*)switc{
    if(self.switchBlock) self.switchBlock(switc);
}
+(instancetype)cellWithNoneImageForTableView:(UITableView *)tableView andunstyle:(UITableViewCellAccessoryType)style{
    switchCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"switchCell"];
    if (!cell) {
        cell = [[switchCellTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"switchCell"];//[[[NSBundle mainBundle] loadNibNamed:@"FCNoteTableViewCell" owner:nil options:nil] lastObject];
    }
    cell.accessoryType=style;
    return cell;
}
+(instancetype)cellWitImageForTableView:(UITableView *)tableView andunstyle:(UITableViewCellAccessoryType)style{
    switchCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"switchCell"];
    if (!cell) {
        cell = [[switchCellTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"switchCell"];
        cell.leftImg = [[UIImageView alloc] initWithFrame:CGRectMake(16, 10, 32, 32)];
        cell.titleLabel.x = cell.leftImg.right+10;
        [cell.contentView addSubview:cell.leftImg];
    }
    cell.accessoryType=style;
    return cell;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
